<!DOCTYPE HTML>
<html>
<HEAD>
<meta charset="utf-8">
<TITLE>待审核积分</TITLE>
</HEAD>
<body>
    
<?php
include_once("base-class.php");

//新建sae数据库类
$mysql = new SaeMysql();

//获取当前页码
$page=intval($_GET["page"]);

//获取操作标识传入
//$action=$_GET["action"];
//$action= string::un_script_code($action);
//$action= string::un_html($action);


//获取员工ID号传入
$roster_id=intval($_GET["id"]);
//列表数据获取、分页
$roster_check=$mysql->getLine("select roster_S,roster_Y,roster_Q,roster_M,roster_C,roster_K,roster_X from roster where roster_id = $roster_id ");
//计算总数
$count=$mysql->getVar("select COUNT(*) from roster,list,gift where roster_name = list_name and list_code = gift_code 
                                      and(( list_code REGEXP '^S' and $roster_check[roster_S] ='1' )
                                      or( list_code REGEXP '^Y' and $roster_check[roster_Y] ='1' )
                                      or( list_code REGEXP '^Q' and $roster_check[roster_Q] ='1' )
                                      or( list_code REGEXP '^M' and $roster_check[roster_M] ='1' )
                                      or( list_code REGEXP '^C' and $roster_check[roster_C] ='1' )
                                      or( list_code REGEXP '^K' and $roster_check[roster_K] ='1' )
                                      or( list_code REGEXP '^X' and $roster_check[roster_X] ='1' ))
                                      and list_status='0'");

$rmb_value_new=$mysql->getVar("select sum(rmb_rmb)*DATE_FORMAT( NOW( ),'%d')/DAYOFMONTH(last_day(curdate())) from rmb where `rmb_addtime` > DATE_FORMAT( NOW( ) ,  '%Y-%m-01' )  and rmb_rmb>0");//当月新增奖金平滑
$rmb_value_old=$mysql->getVar("select sum(rmb_rmb)from rmb where `rmb_addtime` < DATE_FORMAT( NOW( ) ,  '%Y-%m-01' )  or rmb_rmb<0");//历史奖金+兑换奖金                
$rmb_value = $rmb_value_new + $rmb_value_old;
$list_allsum_value=$mysql->getVar("select sum(list_money) from list where list_status = 1 "); //查询总积分
$exchange_rate = $rmb_value/$list_allsum_value; //计算汇率

//如果数据表里有数据
if($count)
{
    //每页显示记录数
    $page_num = 50;
    //如果无页码参数则为第一页
    if ($page == 0) $page = 1;
    //计算开始的记录序号
    $from_record = ($page - 1) * $page_num;
    //获取符合条件的数据
    // $list_list=$mysql->getData("select *
    //          from list where $list_name =  $rostar_name
    //          limit $from_record,$page_num");
    
    // $roster_check=$mysql->getLine("select roster_S,roster_Y,roster_Q,roster_M,roster_C,roster_K,roster_X from roster where roster_openid = $roster_openid ");

        $check_list=$mysql->getData("select list_id,list_name,list_code,gift_item,gift_score,gift_dynamic,list_money,list_addtime,list_status
                                      from roster,list,gift where roster_name = list_name and list_code = gift_code 
                                      and(( list_code REGEXP '^S' and $roster_check[roster_S] ='1' )
                                      or( list_code REGEXP '^Y' and $roster_check[roster_Y] ='1' )
                                      or( list_code REGEXP '^Q' and $roster_check[roster_Q] ='1' )
                                      or( list_code REGEXP '^M' and $roster_check[roster_M] ='1' )
                                      or( list_code REGEXP '^C' and $roster_check[roster_C] ='1' )
                                      or( list_code REGEXP '^K' and $roster_check[roster_K] ='1' )
                                      or( list_code REGEXP '^X' and $roster_check[roster_X] ='1' ))
                                      and list_status='0'
                                      ORDER BY list_addtime DESC limit $from_record,$page_num ");
    //分页函数
    $multi = multi($count, $page_num, $page, "check_list.php");
}
?>
    <!--页面名称-->
	<h3>待审核积分</h3>
    <!--列表开始-->

    <table border=1>
        <tr>
            <td>序号</td><td>姓名</td><td>积分代码</td><td>积分项目(标准分值)</td><td>申请分值</td><td>添加时间</td><td>状态</td>
        </tr>
        <?php
			if($check_list)
            {
                foreach($check_list as $value)
                {
                    
                    //$value["roster_sex"]=($value["roster_sex"]==1)?"男":"女";
                    //$value["roster_status"]=$roster_status_arr[$value["roster_status"]];
                    $value["list_status"]=($value["list_status"]=="0")?"待审核":"审核通过";
                    if ($value[gift_dynamic]==0)
                    {    
                        echo "<tr>
                              <td>$value[list_id]</td>
                              <td>$value[list_name]</td>
                              <td>$value[list_code]</td>
                              <td>$value[gift_item]($value[gift_score] 分)</td>
                              <td>$value[list_money]</td>
                              <td>$value[list_addtime]</td>
                              <td>$value[list_status]</td>
                              
                              <tr>";
                    }
                    else if ($value[gift_dynamic]==1)
                    {    
                        $gift_score_now = round($value[gift_score]/$exchange_rate,1);
                        echo "<tr>
                              <td>$value[list_id]</td>
                              <td>$value[list_name]</td>
                              <td>$value[list_code]</td>
                              <td>$value[gift_item]($gift_score_now 分)</td>
                              <td>$value[list_money]</td>
                              <td>$value[list_addtime]</td>
                              <td>$value[list_status]</td>
                              
                              <tr>";
                    }                    
                }
            }
			else
            {
                echo "<tr><td colspan=7>无记录</td></tr>";
            }
        ?>
    
    </table>
    <?php
	echo $multi;
    ?>
</body>
</html>
